<?php
        session_start();
		

		include 'connect.php';
        $username1=$_POST['username'];// some statements that checks whether the credentials are ok
		$password1=md5(md5($_POST['password']));
		if ($username1 == "" && $password1 == "" ) { header("Location: signin.php?flg=yellow3&username1=".$username1); exit; }
		if ($username1 == "") { header("Location: signin.php?flg=yellow&username1=".$username1); exit; }
		if ( $password1 == "" ) { header("Location: signin.php?flg=yellow2&username1=".$username1); exit; }
		if ($username1 == "" || $password1 == "" ) { header("Location: signin.php?flg=red&username1=".$username1); exit; }
		$sql="SELECT * FROM `temp_users` WHERE `user_name`='$username1'AND `user_pass`='$password1'";
		$validuser=mysql_query($sql)or die("Invalid query: " . mysql_error());
		 if ($validuser) {
		
		
include 'connect.php';
$result = mysql_query($sql);

print_r($row= mysql_fetch_assoc($result));    
   
   $firstname = $row['user_fname'];
    $lastname = $row['user_lname'];
    $regno = $row['user_gender'];
$email=$row['user_email'];
		$dst=$row['user_dst'];
	
		
		
       
			$query1 =  "UPDATE `temp_users` SET `user_active`=1 WHERE `user_name`='$username1'AND `user_pass`='$password1'";
			 mysql_query($query1);
			$row = mysql_fetch_array($result);
               $_SESSION['LOGIN_TYPE'] = $row['user_type'];
			$_SESSION['USERNAME'] = $username1;
			$_SESSION['EMAIL'] = $email;
			$_SESSION['LOGGEDIN'] = true;
			$_SESSION['FNAME'] = $firstname;
			$_SESSION['LNAME'] = $lastname;
			$_SESSION['GENDER'] = $regno;
			$_SESSION['DISTRICT'] =$dst; 
			include'close_connect.php';			
			header("Location: home.php");
			exit;
        }else
		{
		header("Location: signin.php?flg=red&username=".$username1); exit;	
		}
        // some statements 
?>
                   
